import request from '@/utils/request'

/**
 * 获取员工列表
 * @param {*} query 查询参数
 * @returns
 */
export const getEmployeeListAPI = query => {
  return request({
    method: 'get',
    url: '/sys/user',
    params: query
  })
}
/**
 * 删除员工
 * @param {*} employeeId 员工Id
 * @returns
 */
export const delEmployeeAPI = employeeId => {
  return request({
    method: 'delete',
    url: `/sys/user/${employeeId}`
  })
}
/**
 * 新增一个员工
 * @param {*} employeeForm
 * @returns
 */
export const addEmployeeAPI = employeeForm => {
  return request({
    method: 'post',
    url: '/sys/user',
    data: employeeForm
  })
}
// excel批量添加
export const addEmployeeBatchAPI = employeeList => {
  return request({
    method: 'post',
    url: '/sys/user/batch',
    data: employeeList
  })
}

/**
 * 获取员工基本信息
 * @param {*} userId
 * @returns
 */
export const getEmployeeInfoAPI = employeeId => {
  return request({
    method: 'get',
    url: `/sys/user/${employeeId}`
  })
}

/**
 * 编辑(更新)员工信息
 * @param {*} employeeForm
 * @returns Promise
 */
export const updateEmployeeAPI = employeeForm => {
  return request({
    method: 'put',
    url: `/sys/user/${employeeForm.id}`,
    data: employeeForm
  })
}

/**
 * 给员工分配角色
 * @param {*} id 员工id
 * @param {*} roleIds 角色id数组
 * @returns Promise
 */
export const assignRoleAPI = (id, roleIds) => {
  return request({
    method: 'put',
    url: '/sys/user/assignRoles',
    data: {
      id,
      roleIds
    }
  })
}
